package com.todo.content.common.enums;

import lombok.AllArgsConstructor;
import lombok.Getter;

import java.util.Arrays;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * @author zhangwenxiang
 * @date 2024/3/14 20:53
 * @description
 */
@Getter
@AllArgsConstructor
public enum ContentStatusEnum {

    DRAFT(1, "DRAFT", "草稿"),// 暂时内容相关的不通过草稿状态，直接发布就是提交，再进入审核，后续状态细化可以在使用草稿
    POSTED(2, "POSTED", "已提交"),
    EXAMINING(3, "EXAMINING", "审核中"),
    AUTO_EXAMINE_FAILED(4, "AUTO_EXAMINE_FAILED", "自动审核失败转人工审核"),
    EXAMINE_FAILED(5, "EXAMINE_FAILED", "人工审核失败"),
    PUBLISHED(6, "PUBLISHED", "已发布"),
    DISABLE(7, "DISABLE", "已禁用"),


    DISCARD(99, "DISCARD", "废弃"),

    ;

    private static Map<Integer, ContentStatusEnum> typeMap = Arrays
            .stream(ContentStatusEnum.values())
            .collect(Collectors.toMap(ContentStatusEnum::getType, item -> item, (v1, v2) -> v2));

    private int type;
    private String code;
    private String name;


    public static ContentStatusEnum getByType(Integer type) {
        return typeMap.get(type);
    }
}
